package com.lc.qianrenshiye.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/11/30.
 */
//    排序	参数名	参数类型	是否必须	说明
//    0	sid	string	是	商店id
//    0	uid	string	是	用户id
//    0	pay	string	是	支付状态；0，未付款；1，已付款
//    0	time1	string	是	时间1
//    0	time2	string
@HttpInlet(Conn.ORDER_INDEX)
public class OrderListPost extends BaseAsyPost<OrderListPost.OrderListEntity> {

    public String sid, uid, pay, time1, time2;

    public OrderListPost(AsyCallBack<OrderListEntity> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected OrderListEntity parser(JSONObject object) throws Exception {

        TOAST = object.optString("message");

        if (object.optInt("code") == 200) {

            OrderListEntity orderListEntity = new OrderListEntity();

            JSONArray array = object.optJSONArray("list");

            if (array != null) {

                for (int i = 0; i < array.length(); i++) {

                    JSONObject entityObject = array.optJSONObject(i);

                    OrderEntity orderEntity = new OrderEntity();

                    orderEntity.id = entityObject.optString("id");
                    orderEntity.sid = entityObject.optString("sid");
                    orderEntity.uid = entityObject.optString("uid");
                    orderEntity.posttime = entityObject.optString("posttime");
                    orderEntity.amount = entityObject.optString("amount");
                    orderEntity.paystatus = entityObject.optString("paystatus");
                    orderEntity.num = entityObject.optString("num");
                    orderEntity.ordersn = entityObject.optString("ordersn");
                    orderEntity.addnumber = entityObject.optString("addnumber");
                    orderEntity.number = entityObject.optString("number");
                    orderEntity.seats = entityObject.optString("seats");

                    orderListEntity.orderEntityList.add(orderEntity);

                }

            }


            return orderListEntity;
        }

        return null;

    }

    public static class OrderListEntity {

        public List<OrderEntity> orderEntityList = new ArrayList<>();
    }

    public static class OrderEntity {

//        "amount": "60.00",
//                "uid": 1,
//                "id": 44,
//                "sid": 1,
//                "num": 2,
//                "ordersn": "201611309851545244",
//                "addtime": "11-30-2016 14:25",
//                "paystatus": 0,
//                "addnumber": "",
//                "number": "2",
//                "seats": "13"


//        "amount": "120.00",
//                12-23 11:13:00.799 5583-5597/? E/Http:             "uid": 1,
//                12-23 11:13:00.799 5583-5597/? E/Http:             "id": 4,
//                12-23 11:13:00.799 5583-5597/? E/Http:             "sid": 1,
//                12-23 11:13:00.799 5583-5597/? E/Http:             "num": 4,
//                12-23 11:13:00.799 5583-5597/? E/Http:             "ordersn": "20161215525550104",
//                12-23 11:13:00.799 5583-5597/? E/Http:             "paystatus": 0,
//                12-23 11:13:00.799 5583-5597/? E/Http:             "posttime": "12-15-2016 10:19:48",
//                12-23 11:13:00.799 5583-5597/? E/Http:             "seats": "12"
        public String id, sid, uid, posttime, amount, paystatus, num, ordersn, addnumber, number, seats;


    }

}
